# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-applications
pkgname=mailcommon
pkgver=24.02.2
pkgrel=0
pkgdesc="KDE PIM library providing support for mail applications"
# riscv64 disabled due to missing rust in recursive dependency
# ppc64le, s390x, armhf, riscv64 and armv7 blocked by messagelib -> qt6-qtwebengine
arch="all !ppc64le !s390x !armhf !riscv64 !armv7"
url="https://kontact.kde.org/"
license="GPL-2.0-or-later"
# TODO: Consider replacing gnupg with specific gnupg subpackages that mailcommon really needs.
depends="gnupg"
depends_dev="
	akonadi-dev
	akonadi-mime-dev
	karchive-dev
	kcodecs-dev
	kcompletion-dev
	kconfig-dev
	kconfigwidgets-dev
	kdbusaddons-dev
	ki18n-dev
	kiconthemes-dev
	kio-dev
	kitemmodels-dev
	kitemviews-dev
	kmailtransport-dev
	ktextwidgets-dev
	kwidgetsaddons-dev
	kwindowsystem-dev
	kxmlgui-dev
	libkdepim-dev
	mailimporter-dev
	messagelib-dev
	qt6-qtbase-dev
	qt6-qttools-dev
	syntax-highlighting-dev
	"
makedepends="
	$depends_dev
	extra-cmake-modules
	samurai
	"
checkdepends="
	dbus
	xvfb-run
	"
subpackages="$pkgname-dev $pkgname-lang"
_repo_url="https://invent.kde.org/pim/mailcommon.git"
source="https://download.kde.org/stable/release-service/$pkgver/src/mailcommon-$pkgver.tar.xz"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	local skipped_tests="("
	local tests="
		akonadi-mysql-filterimportthunderbird
		akonadi-sqlite-filterimportthunderbird
		akonadi-sqlite-filterimportbalsa
		akonadi-mysql-filterimportsylpheed
		mailcommon-filter-filteractionencrypt
		akonadi-mysql-foldertreewidget
		akonadi-sqlite-foldertreewidget
		akonadi-mysql-favorites
		akonadi-sqlite-favorites
		"
	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done
	skipped_tests="$skipped_tests)test"
	dbus-run-session xvfb-run ctest --test-dir build --output-on-failure -E "$skipped_tests"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
d88e49e8efe5891a629cb37d425b60e2607174643c0ffe6dca67e971ff50ae32d47ed706fc57a41052be5edbeaa819a3bce69cf9907d0ac98e62df53625feeec  mailcommon-24.02.2.tar.xz
"
